using Godot;
using System;

namespace Box;
public partial class BooleanPropertyControl : HBoxContainer,IProperty
{
	public bool pvalue = false;
	public object PValue {
		get {
			if(input == null) return pvalue;
			return input.ButtonPressed;
		}

		set {
			if(input == null) {
				pvalue = (Boolean)value;
				return;
			}
			input.ButtonPressed = (Boolean)value;
		}
	}
	public string PName{get;set;}
	CheckBox input;
	Label label;

	public override string ToString() {
		return (Boolean)PValue ? "true" : "false";
	}

	public override void _Ready()
	{
		label = GetNode<Label>("Label");
		label.Text = PName;
		input = GetNode<CheckBox>("Input");
		input.Toggled += s => {
			PValue = s;
		};
		input.ButtonPressed = pvalue;
	}
}
